﻿/*
	Copyright (C) 2019 Zongming Liu <1849059316@qq.com>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License along
	with this program; if not, write to the Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef TextureCache_h__
#define TextureCache_h__
#include "../utility/NonCopyable.h"
#include <memory>
#include <unordered_map>

namespace SkyEngine2d
{
	
	class Texture2D;
	
	/*!
	 \brief 2D纹理缓存
	 \details
	*/
	class TextureCache
		:NonCopyable
	{
	public:
	
		//! 构造
		TextureCache();
		
		//! 析构 
		~TextureCache();
		
		//! 添加纹理图片到缓存，然后返回2D纹理
		/*!
		\param std::wstring file 图片路径
		\return std::shared_ptr<Texture2D>
		\note 如果图片已经存在缓存中，那么会直接返回缓存中的2d纹理
		*/
		std::shared_ptr<Texture2D> addImage(std::wstring file);
	private:
		std::unordered_map<std::wstring, std::shared_ptr<Texture2D>> m_textures;
	};
}


#endif // TextureCache_h__
